home *** CD-ROM | disk | FTP | other *** search
- ########################################################################
- # Module : hstrings.hsm
- # Description: Functions related with strings.
- # Maintainer : Juergen Haible <juergen.haible@t-online.de>
- # Version : 2000-05-07
- ########################################################################
- # NOTE:
- # This module is delivered with Hamster and it will be overwritten when
- # installing a new version of it. It might also be used by accompanying
- # demo-scripts, which depend on the current implementation.
- # So do NOT change this file unless you REALLY know what you do!
- ########################################################################
-
- #!initialize
- debug( 255, "<<< module 'hstrings.hsm' >>>" )
- varset( $CRLF , chr(13) + chr(10) )
- varset( $WSP , chr(32) + chr( 9) )
- return( 0 )
-
- ########################################################################
- # TrimWSP: Removes leading and trailing whitespace
- ########################################################################
- # [IN] $string : line of text
- # [OUT] (result): $string with whitespace removed
- # Example: print( TrimWSP( $line ) )
-
- sub TrimWSP( $string )
- return( Trim( $string, $WSP ) )
- endsub
-
- ########################################################################
- # PosWSP: Position of first whitespace-character within string
- ########################################################################
- # [IN] $string : line of text
- # [OUT] (result): position of first whitespace-char; 0 if none
- # Example: print( PosWSP( $line ) )
-
- sub PosWSP( $string )
- var( $is, $it )
- $is = Pos( " ", $string )
- if( $is=0 )
- return( Pos( chr(9), $string ) )
- else
- $it = Pos( chr(9), $string )
- return( iif( ($it>0) && ($it<$is), $it, $is ) )
- endif
- endsub
-